{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "83b7c0c0",
   "metadata": {},
   "source": [
    "* 2022/09/06/week03 \n",
    "* python课堂笔记\n",
    "* 记录人：大阳\n",
    "> 回顾变量\n",
    ">\n",
    "> 条件判断\n",
    "> "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e5e83fc3",
   "metadata": {},
   "source": [
    "# 回顾变量的概念\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f258409c",
   "metadata": {},
   "outputs": [],
   "source": [
    "网新_01_ID = \"2100001\" "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "286f1663",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2100001'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_01_ID"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bc9dff76",
   "metadata": {},
   "source": [
    "# 条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b06d5e6c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 先创建变量，在进行判断\n",
    "# if语句 观察条件判断块的位置\n",
    "# 按照条件块的间隙 找归属关系\n",
    "today = \"Sunday\"\n",
    "condition = \"good\"\n",
    "\n",
    "if today == \"Saturday\":\n",
    "    print(\"超开心\")\n",
    "elif today"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "69569ca2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "91e5d625",
   "metadata": {},
   "outputs": [],
   "source": [
    "wday = time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "7ffb43a2",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_hour=time.localtime().tm_hour"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "9d4c3ba4",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_min=time.localtime().tm_min"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "734ca4a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "python课ing\n"
     ]
    }
   ],
   "source": [
    "if wday != 1:\n",
    "    print(\"无python课堂\")\n",
    "elif time_hour == 12 and time_min > 50:\n",
    "        print(\"python课ing\")\n",
    "elif time_hour == 13:\n",
    "        print(\"python课ing\")\n",
    "elif time_hour == 14:\n",
    "        print(\"python课ing\") \n",
    "elif time_hour == 15:\n",
    "        print(\"python课ing\") \n",
    "elif time_hour == 16 and time_min < 50:\n",
    "        print(\"python课ing\") \n",
    "else:\n",
    "        print(\"今天有python课 ，上课时间为下午12：50-16：50\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89939270",
   "metadata": {},
   "source": [
    "# for循环 内置函数range（）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e08aed65",
   "metadata": {},
   "source": [
    "## 用例1 循环迭代数字变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "72f1d102",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "for item in [1,2,3]:\n",
    "     print(item)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "483b80a6",
   "metadata": {},
   "source": [
    "## 用例2 循环迭代字符串变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "8a7d66bf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hi!\n"
     ]
    }
   ],
   "source": [
    "for ch in [\"hi!\"]:\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e4d1310b",
   "metadata": {},
   "source": [
    "# Random模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "0a0b4bae",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "795acf9d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5510722315886379"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "29b921e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "45"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(1,50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "66e84635",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "56\n",
      "现在是秒/时间为偶数\n",
      "59\n",
      "现在是秒/时间为奇数\n",
      "2\n",
      "现在是秒/时间为偶数\n",
      "5\n",
      "现在是秒/时间为奇数\n",
      "8\n",
      "现在是秒/时间为偶数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "odds = [  1, 3, 5, 7, 9, 11,13,15,17,19,\n",
    "           21,23,25,27,29,31,33,35,37,39,\n",
    "            41,43,45,47,49,51,53,55,57,59]\n",
    "for i in range(5):\n",
    "    right_this_minute = datetime.datetime.today().second\n",
    "    if right_this_minute in odds:\n",
    "        print(right_this_minute)\n",
    "        print(\"现在是秒/时间为奇数\")\n",
    "    else:\n",
    "        print(right_this_minute)\n",
    "        print(\"现在是秒/时间为偶数\")\n",
    "    time.sleep(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "8798c340",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "4d2c858d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "time.sleep(3)\n",
    "print(\"hello world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2fe4ba20",
   "metadata": {},
   "outputs": [],
   "source": [
    "# python控制键盘-木马的实现"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
